package com.lottery.material.service.admin.conf.impl;

import com.lottery.material.dao.conf.AreaDictMapper;
import com.lottery.material.pojo.conf.AreaDict;
import com.lottery.material.service.admin.conf.AreaDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description：区域字典服务接口实现类
 * Created by 朱正磊 on 2019-05-14 17:32
 */
@Service("adminAreaDictService")
public class AreaDictServiceImpl implements AreaDictService {

    private final AreaDictMapper areaDictMapper;

    @Autowired
    public AreaDictServiceImpl(AreaDictMapper areaDictMapper) {
        this.areaDictMapper = areaDictMapper;
    }

    /**
     * description：新增一条数据
     * user 朱正磊
     * time 2019-04-20 15:14
     * @param areaDict 对象
     * @return 返回持久化操作数据库状态值
     */
    @Override
    public Integer add(AreaDict areaDict) {
        return areaDictMapper.insertSelective(areaDict);
    }

    /**
     * description：根据主键物理删除
     * user 朱正磊
     * time 2019-04-20 15:13
     * @param id 主键
     * @return 返回持久化操作数据库状态值
     */
    @Override
    public Integer deleteById(Integer id) {
        return areaDictMapper.deleteByPrimaryKey(id);
    }

    /**
     * description：根据主键查询唯一数据
     * user 朱正磊
     * time 2019-04-20 15:15
     * @param id 主键
     * @return 返回唯一数据
     */
    @Override
    public AreaDict findById(Integer id) {
        return areaDictMapper.selectByPrimaryKey(id);
    }

    /**
     * description：根据主键修改一条数据
     * user 朱正磊
     * time 2019-04-20 15:16
     * @param areaDict 对象
     * @return 返回持久化操作数据库状态值
     */
    @Override
    public Integer updateById(AreaDict areaDict) {
        return areaDictMapper.updateByPrimaryKeySelective(areaDict);
    }

    /**
     * description：根据地区id查询区域字典数据
     * user 朱正磊
     * time 2019-05-17 17:01
     * @param regionId 地区id
     * @return 返回区域字典数据
     */
    @Override
    public AreaDict findByRegionId(Integer regionId) {
        return areaDictMapper.findByRegionId(regionId);
    }

    /**
     * description: 根据父id查询
     * author sunny
     * createDate 2019-05-15 下午 4:54
     * @param parentId
     * @return
     */
    @Override
    public List<AreaDict> findByParentId(Integer parentId) {
        return areaDictMapper.findByParentId(parentId);
    }

}
